package com.example.park2212.payer

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.alibaba.android.arouter.facade.annotation.Route
import com.blankj.utilcode.util.ToastUtils
import com.example.lib_base.entity.PayerBeanItem
import com.example.lib_base.mvvm.BaseActivity
import com.example.park2212.R
import com.example.park2212.databinding.ActivityPayerAddBinding
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
@Route(path = "/app/payer/PayerAddActivity")
class PayerAddActivity : BaseActivity<ActivityPayerAddBinding,PayerViewModel>() {
    override fun initView() {
        binding.payerAddHead.headerBack.setOnClickListener {
            finish()
        }
        binding.payerAddHead.headerTitle.setText("新增临时收费")

        binding.btnYes.setOnClickListener {
            val etInfo = binding.payerAddEtinfo.text.toString()
            val etXm = binding.payerAddEtxm.text.toString()
            val etNum = binding.payerAddEtnum.text.toString()
            val etZpirce = binding.payerAddEtzprice.text.toString()
            val etStartTime = binding.payerAddEtstartTime.text.toString()
            val etEndTime = binding.payerAddEtendTIME.text.toString()
            val beanItem = PayerBeanItem(
                etInfo, etNum, 6,
                1, etEndTime, "3", "微信", "未缴费",
                etStartTime, etXm, etZpirce.toInt(), "TX20250306002"
            ,false)
            viewModel.payerAdd(beanItem)
            viewModel.getPayer(1)

        }

        binding.payerAddTvstartTime.setOnClickListener {
            showDateDialog(binding.payerAddEtstartTime)
        }

    }

    override fun initData() {
        viewModel.payerAddSuccess.observe(this){
            ToastUtils.showLong("新增成功")
            finish()
        }

    }

}